package net.hn.hnms.biz.performance.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.performance.request.PerformanceScoringAndDetailsReq;
import net.hn.hnms.biz.performance.request.PerformanceScoringReq;
import net.hn.hnms.biz.performance.request.SafetyHazardReq;
import net.hn.hnms.biz.performance.service.PerformanceScoringService;
import net.hn.hnms.biz.performance.vo.PerformanceScoringVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "绩效打分", tags = {"绩效指标"})
@RestController
@RequestMapping("/performanceScoring/management")
public class PerformanceScoringController {


    @Autowired
    private PerformanceScoringService performanceScoringService;


    @GetMapping("/page")
    @ApiOperation("绩效打分-分页查询")
    public R<Page<List<PerformanceScoringVo>>> page(PageQuery pageQuery, PerformanceScoringReq req) {
        return R.ok(performanceScoringService.getPerformanceScoringByNameAndScoringTypeAndScoringDateAndScoringTemplateId(pageQuery, req));
    }


    @PostMapping("/add")
    @ApiOperation("绩效打分-打分")
    public R add(@RequestBody PerformanceScoringAndDetailsReq req) {

        return R.ok(performanceScoringService.save(req));
    }

    @PostMapping("/update")
    @ApiOperation("绩效打分-修改")
    public R update(@RequestBody PerformanceScoringReq req) {
        return R.ok(performanceScoringService.update(req));
    }

    @DeleteMapping("/delete")
    @ApiOperation("绩效打分-删除")
    public R delete(@RequestParam("ids") List<String> ids) {
        return R.ok(performanceScoringService.deleteById(ids));
    }


    @GetMapping("/getSafetyHazard")
    @ApiOperation("安全绩效考核-获取各类隐患数")
    public R getSafetyHazard(SafetyHazardReq req) {
        return R.ok(performanceScoringService.getSafetyHazard(req));
    }



}
